var contacts_object = new contactsClass();
var cities = new Array ();
var phones = new Array ();

function contactsClass() {
  this.contacts = new Array();
 	
  this.compileArray = function() {
    for (var i = 0; i <= cities.length-1; i++) {
      this.contacts[i] = new Array(cities[i], phones[i]);
    }
  }

  this.getCity = function(id) {
    out = new Array();
    out[0]	= this.contacts[id];
    this.contacts.sort();
    for(var i = 0; i <= this.contacts.length-1; i++) {
      if(this.contacts[i][0] != out[0][0]) {
        out[out.length] = this.contacts[i];
      }
    }
    this.contacts=out;
    return out;
  }

  this.getPhone = function(id) {
    var out = this.contacts[id][1];
    return out;
  }
		
  this.buildList = function(id) {
    var cm = document.getElementById("contacts_menu");
    var cpt = document.getElementById('contacts_phone_text');
    if((cm != null) && (cpt != null)) {
        arr = new Array();
        arr = this.getCity(id);
        var html = "<ul >";
        for (var i=0; i <= arr.length-1; i++) {
            if (i == 0)	{
                html += '<li class="contacts_link_active" >'+arr[i][0]+'</li>';
            }
            else {
                html += '<li class="contacts_link"  onclick="javascript:contacts_object.buildList('+i+')">'+arr[i][0]+'</li>';
            }
        }
        html += "</ul>";
        cm.innerHTML = html;
        cpt.innerHTML = contacts_object.getPhone(0);
        menuOut();
    }
  }
};

function menuHover() {
  jQuery('#contacts_menu').removeClass('contacts_menu_default');
  jQuery('#contacts_menu').addClass('contacts_menu_hover');
};

function menuOut() {
  jQuery('#contacts_menu').removeClass('contacts_menu_hover');
  jQuery('#contacts_menu').addClass('contacts_menu_default');
};